import 'package:flutter/material.dart';
import 'package:flutter_learn_vi/src/bean/bean_category.dart';

class NewsSelectTab extends StatefulWidget {
  final CategoryItemBean element;
  final int eIndex;
  final int selectIndex;

  const NewsSelectTab({Key key, this.element, this.eIndex, this.selectIndex})
      : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return NewsSelectTabState();
  }
}

class NewsSelectTabState extends State<NewsSelectTab> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(top: 8, bottom: 8),
      padding: EdgeInsets.only(left: 8, right: 8,top: 4,bottom: 4),
      decoration: BoxDecoration(
          color: isSelect() ? Colors.red : Colors.grey[200],
          borderRadius: BorderRadius.all(Radius.circular(20))),
      alignment: Alignment.center,
      child: Text(
        widget.element.categoryName,
        style: TextStyle(
            color: isSelect() ? Colors.white : Colors.grey[600], fontSize: 14),
      ),
    );
  }

  bool isSelect() {
    return widget.selectIndex == widget.eIndex;
  }
}
